﻿using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    { 
         
        private void TSTEKSMP(DataSet db)  
        {
            try
            {
                DataTable tbEKKOPF = dsSource.Tables["EKKOPF"];
                DataRow dwEKKOPF = tbEKKOPF.Rows[0];
                string src = "";

                src = dwEKKOPF["ORDNO"].ToString();
                exAgent.SetCellValue(3, 2, src);
                src = dwEKKOPF["SUPP"].ToString().Trim();
                exAgent.SetCellValue(3, 4, src);
                src = dwEKKOPF["ORDDAT"].ToString().Trim();
                exAgent.SetCellValue(3, 6, src);
                src = dwEKKOPF["CUSTOMER"].ToString().Trim();
                exAgent.SetCellValue(9, 3, Helper.GetGB2312Value(src));
                src = dwEKKOPF["SACHBE"].ToString().Trim();
                exAgent.SetCellValue(9, 6, Helper.GetGB2312Value(src));                
                src = Helper.GetGB2312Value(dwEKKOPF["INVNAME"].ToString().Trim()) + System.Environment.NewLine + Helper.GetGB2312Value(dwEKKOPF["INVADR"].ToString().Trim());
                exAgent.SetCellValue(5, 1, src);
                src = Helper.GetGB2312Value(dwEKKOPF["DELNAME"].ToString().Trim()) + System.Environment.NewLine + Helper.GetGB2312Value(dwEKKOPF["DELADR"].ToString().Trim());
                exAgent.SetCellValue(5, 4, src);
                exAgent.SetCellValue(8, 1, "LeadTime:");
                exAgent.SetCellValue(8, 2, dwEKKOPF["LSLIEFDAT"].ToString()+"d");
                DataTable tbEKPOS = dsSource.Tables["EKPOS"];
                int x = 11;
                foreach (DataRow dwEKPOS in tbEKPOS.Rows)
                {
                    src = dwEKPOS["ART"].ToString().Trim() + System.Environment.NewLine + dwEKPOS["ARTDES"].ToString().Trim();
                    exAgent.SetCellValue(x, 1, Helper.GetGB2312Value(src));
                     
                    exAgent.SetCellValue(x, 2, dwEKPOS["WAFMINPMENG"].ToString());
                    src = dwEKPOS["COLOR"].ToString().Trim();
                    exAgent.SetCellValue(x, 3, Helper.GetGB2312Value(src));
                    src = dwEKPOS["QTY"].ToString().Trim()+ dwEKPOS["UNIT"].ToString().Trim();
                    exAgent.SetCellValue(x, 4, Helper.GetGB2312Value(src));                   
                    src = dwEKPOS["BDAT"].ToString().Trim();
                    if (src.Trim() == "0") src = "";
                    exAgent.SetCellValue(x, 6, src);                    
                    x = x + 1;

                }
                
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);

            }            
        }
               
    }
}
